Ext.define('Intranet.Desktop.controller.MainScreen', {
    extend: 'Ext.app.Controller',
	
    views: [
	'Intranet.Desktop.view.MainScreen',
        'Intranet.Desktop.view.CompanyPanel',
        'Intranet.Desktop.view.TeamGroupsPanel',
        'Intranet.Desktop.view.PersonalPanel'
    ],

    init : function() {
        this.control({

            'panel button[id=toolboxBtn]' : {
                afterrender : this.onPanelRendered
            },
            
            'panel button[action=showHideToolbox]' : {
                toggle : this.onSlideInSlideOutRequest
            }
 
        });
    },
 
    onPanelRendered : function(thisPanel, eOpts ) {

        
        var toolboxBtn = Ext.getCmp('toolboxBtn');
        if(toolboxBtn.pressed === true)
            {
                Ext.getCmp("toolbox").hide();
            }
    },

    onSlideInSlideOutRequest : function(button, pressed) {
        var toolboxCmp = Ext.getCmp("toolbox");
        if(toolboxCmp.isHidden() === true)
            {
                toolboxCmp.show();
            }
            
        var toolboxEl = Ext.get("toolbox");
        if(pressed){
         
            toolboxEl.slideOut('r', {
                easing: 'easeOut',
                duration: 1000,
                remove: false,
                useDisplay: false
            });
        }
        else {
         
            toolboxEl.slideIn('r', {
                easing: 'easeOut',
                duration: 1000
            });
        }
    }

    
});